 <?php 

class AclHelper extends AppHelper {
    var $helpers = array('Session','Html','Permission');

	public function __construct(View $view, $settings = array()) {
        parent::__construct($view, $settings);
    }
	
    function link($name, $url, $options=array(), $c=null,$d=null, $returnText=false, $hidden=false){
    	if (is_string($url)) {
	    	$path="controllers".$url;
    	} else if (is_array($url)) {
    		$path="controllers/".$url["controller"]."/".$url["action"];
    	}
        if($this->Permission->check(strtolower($path))){
            return($this->Html->link($name,$url,$options,$c,$d));
        } else {
        	if (!$hidden) {
	        	//gestire la possibilità di renderlo disabilitato
	        	
				if (isset($options["class"])) {
					$options["class"].= " disabled";
				} else {
					$options["class"]="disabled";
				}
	            return($this->Html->link($name,$url,$options,$c,$d));
        	}
        }
        if($returnText) return $name;
        else return "";
  }

}
?> 